package Model.Visible;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

import Model.Player.Player;
import Utils.ConstantsImplement;

public class Ship extends VisibleElements implements ConstantsImplement{
	private Player player_;
	private int attack_;
	private int speed_;
	private int hp_;
	private int lvl_;
	private Planet currentPlanet_;
	private Planet toAttackPlanet_;
	//-------------NEW 
	private double a_;
	private double b_;
	
	
	public Ship( Point position, int lvl){
		super( position );
		lvl_ = lvl;
		attack_ = ATTACK_SHIP;
	}
//	-- Not used --
//	public void move(){
//		double x0 = this.rectangle_.getCenterX(), y0 = this.rectangle_.getCenterX(), x02 = Math.pow(x0,2),
//				y02 = Math.pow(y0, 2);
//		Double x1 = new Double(0);
//		x1 = Double.valueOf(((x02 + Math.pow(b_, 2) - 2*b_*y0 + y02- speed_)/
//							(-1 + 2*x0 - Math.pow(a_, 2) - 2*a_*b_ + 2*a_*y0)));
//		this.getPosition_().x = x1.intValue();
//		x1 = Double.valueOf(a_*x1.doubleValue() + b_);
//		this.getPosition_().y = x1.intValue();
//		// -- Problem this.rectangle_.set;
//		
//	}
//	
//	public void calculateCurve(){
//		a_ = (this.currentPlanet_.rectangle_.getCenterY() - toAttackPlanet_.rectangle_.getCenterY() ) / 
//				( this.currentPlanet_.rectangle_.getCenterX() - toAttackPlanet_.rectangle_.getCenterX());
//		b_ = this.currentPlanet_.rectangle_.getCenterY() - (a_ * currentPlanet_.rectangle_.getCenterX());
//	}
//	
//	/**
//	 * Problem !!!!!!!!!!!=----------------------------
//	 * using parameter
//	 */
//	public boolean arrive( Rectangle planet){
//		return rectangle_.intersects(planet);
//	}
//	
//	public void changePlanet( ){
//		currentPlanet_ = toAttackPlanet_;
//		toAttackPlanet_ = null;
//	}
	
	public int takeDamage(int attack){
		if ( hp_ >= attack){
			hp_ -= attack;
			return 0;
		}
		if ( hp_ < attack){
			int i = attack - hp_;
			hp_ = 0;
			return i;
		}
		return 0;
	}

	public int getAttack_() {
		return attack_;
	}

	public void setAttack_(int attack_) {
		this.attack_ = attack_;
	}

	public Player getPlayer_() {
		return player_;
	}

	public void setPlayer_(Player player_) {
		this.player_ = player_;
	}
	
	public boolean isDead(){
		if(hp_ <= 0){
			return true;
		}
		return false;
	}
	
	public int getLevel(){
		return lvl_;
	}

	public void updateLvl() {
		// TODO Auto-generated method stub
		lvl_++;
		attack_ += SHIP_ATTACK_INCREMENT;
	}
	
	public int getHp_() {
		return hp_;
	}
}
